#include "utils.hpp"

namespace jizhe {

uint64_t GetRunningCoID() {
    return jizhe::Coroutine::GetRunningCoID();
}

std::string GetCurrentTime() {
    auto now = std::chrono::system_clock::now();
    std::time_t now_c = std::chrono::system_clock::to_time_t(now);
    std::tm tm = *std::localtime(&now_c);
    char buffer[80];
    std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", &tm);
    return buffer;
}

std::string GetCurrentFile(std::string f) {
    std::string filePath = f;
    std::size_t found = filePath.find_last_of("/\\");
    std::string fileName = filePath.substr(found + 1);
    return fileName;
}

uint64_t GetThreadID() {
    return syscall(SYS_gettid);
}

}